<template>
  <div class="body" :style="'min-height:'+innerHeight+'px'">
    <Header />
    <Nuxt />
    <Footer />
  </div>
</template>
<script>
import { mapState, mapMutations } from 'vuex'

export default {
  data () {
    return {
      innerHeight: '0'
    }
  },
  computed: {
    ...mapState('header', ['isError'])
  },
  mounted () {
    if (window && window.innerHeight) {
      this.innerHeight = window.innerHeight
    }

    window.addEventListener('scroll', this.handleScroll)
  },
  methods: {
    ...mapMutations('header', ['setIsScroll']),
    handleScroll () {
      // 获取滚动时的高度
      const scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
      if (!this.isError) {
        this.setIsScroll(scrollTop <= 70)
      }
    }
  }
}
</script>
<style lang="scss">
body{
  min-width: 1200px;
  background: #f5f5f5;
}
</style>
